﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Text;
using System.Drawing;

namespace BusinessClass
{
    /// <summary>
    /// 有些字体的样式需要特别设置，所以提取出一个构造类
    /// </summary>
    public class FontBuilder
    {
        PrivateFontCollection privateFontCollection = new PrivateFontCollection();
        public FontBuilder(string ttfPath, float fontSize, bool bold)
        {
            privateFontCollection.AddFontFile(ttfPath);
            var name = Common.getFileName(ttfPath);
            if (name.Contains("msyhbd"))
            {//微软雅黑粗体 msyhbd一定要使用FontStyle.Bold  不然会提示这个字体不支持Regular
                TheFont = new Font(privateFontCollection.Families[0], fontSize, FontStyle.Bold);
            }
            else
            {
                var fs = bold == true ? FontStyle.Bold : FontStyle.Regular;
                TheFont = new Font(privateFontCollection.Families[0], fontSize, fs);
            }
        }
        public Font TheFont { get; set; }
    }
}
